package cn.tedu.m2;

import org.springframework.amqp.core.Queue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

import javax.annotation.PostConstruct;

@SpringBootApplication
public class Main {
    @Autowired
    private producer p;

    public static void main(String[] args) {
        SpringApplication.run(Main.class, args);
    }

    @PostConstruct
    public void test2(){
 /*       new Thread(new Runnable() {
            @Override
            public void run() {
                 p.send();
            }
        }).start();*/
        //简化开启新的线程来发送消息
        new Thread(() -> p.send()).start();
    }

    @Bean
   public Queue taskQueue(){
        return new Queue("task_queue", true);//默认为true,false,false
   }
}
